<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2022-04-21 15:27:13
 * @LastEditors: Sam
 * @LastEditTime: 2022-05-05 23:04:08
 */
use app\admin\model\AuthRule as AuthRuleModel;

if (!AuthRuleModel::where('title', '秒杀管理')->count()) {

    $parent_id = AuthRuleModel::query()->create([
        'parent_id'    => 0,
        'title'        => '秒杀管理',
        'url'          => '#',
        'method'       => 'OPTIONS',
        'slug'         => 'seckill'
    ]);
    $parent_id_1 =  AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '秒杀活动',
        'url'          => 'seckill_index',
        'method'       => 'GET',
        'slug'         => 'seckill.index'
    ]);
    $parent_id_2 =  AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '秒杀订单',
        'url'          => 'seckill_order',
        'method'       => 'GET',
        'slug'         => 'seckill.order'
    ]);
     AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_2->id,
        'title'        => '订单详情',
        'url'          => 'seckill_order_detail',
        'method'       => 'GET',
        'slug'         => 'seckill.order_detail'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_2->id,
        'title'        => '订单导出',
        'url'          => 'seckill_order_export',
        'method'       => 'GET',
        'slug'         => 'seckill.baragin_order_export'
    ]);
    $parent_id_3 =  AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '秒杀记录',
        'url'          => 'seckill_log',
        'method'       => 'GET',
        'slug'         => 'seckill.log'
    ]);

    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_3->id,
        'title'        => '秒杀记录导出',
        'url'          => 'seckill_log_export',
        'method'       => 'POST',
        'slug'         => 'seckill.seckill_log_export'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '添加秒杀',
        'url'          => 'seckill_create',
        'method'       => 'POST',
        'slug'         => 'seckill.create'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '编辑秒杀',
        'url'          => 'seckill_edit',
        'method'       => 'POST',
        'slug'         => 'seckill.edit'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '删除秒杀',
        'url'          => 'seckill_delete',
        'method'       => 'POST',
        'slug'         => 'seckill.delete'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '添加库存',
        'url'          => 'seckill_add_stock',
        'method'       => 'POST',
        'slug'         => 'seckill.add_stock'
    ]); 
}
